package com.linwen.excise.leetcode;

import java.util.HashSet;
import java.util.Set;

/**
 * @ClassName _2586统计范围内的元音字符串数
 * @Description TODO
 * @Author zero
 * @DATE 2024/9/22 11:28 AM
 * @Version 1.0
 */
public class _2586统计范围内的元音字符串数 {

    static Set<Character> set = new HashSet<>();
    static {
        set.add('a');
        set.add('e');
        set.add('i');
        set.add('o');
        set.add('u');
    }

    public static void main(String[] args) {
        _2586统计范围内的元音字符串数 inst = new _2586统计范围内的元音字符串数();
        String[] arr = new String[]{"hey", "aeo", "mu", "ooo", "artro"};
        int left = 1;
        int right = 4;
        System.out.println(inst.vowelStrings(arr, left, right));
    }

    public int vowelStrings(String[] words, int left, int right) {
        int result = 0;
        for (int i = left; i <= right; i++) {
            String word = words[i];
            if (set.contains(word.charAt(0)) && set.contains(word.charAt(word.length() - 1))) {
                result++;
            }
        }
        return result;
    }

}
